< previous page page_491 next page >

Page 491
You execute the same query on different connections.
You can create prepared statements that are optimized and saved on the database server while the connection is active. This can help speed up execution of SQL statements that are frequently repeated in an application.
You can use it to execute an action query such as INSERT, UPDATE, or DELETE.
Examples Filename: Command.frm
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdCommand1_Click()
   Dim oCmd As Command
   Dim oRS As Recordset
   Dim strSQL As String

   strSQL = "SELECT "
   strSQL = strSQL & "szLast_nm, "
   strSQL = strSQL & "sFirst_nm "
   strSQL = strSQL & "FROM tblEmployees "

   Set oRS = New Recordset
   With oRS
      .CursorType = adOpenForwardOnly
      .LockType = adLockReadOnly
   End With

   Set oCmd = New Command
   With oCmd
      .CommandText = strSQL
      .CommandType = adCmdText
      .ActiveConnection = ConnectString()
      Set oRS = .Execute
   End With

   lstNames.Clear
   Do Until oRS.EOF
      lstNames.AddItem oRS("szLast_nm") & _
                         ", " & oRS("sFirst_nm")
      oRS.MoveNext
   Loop

 
< previous page page_491 next page >

If you like this book, buy it!